package com.tfh.strategy;

import java.math.BigDecimal;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

public class DayMeanAlloter extends Alloter {
    private static List<BigDecimal> toAmount(RentAmount rent) {
        BigDecimal amount = rent.dayAmount();
        return rent.dayRange().stream().map((Long day) -> amount.multiply(BigDecimal.valueOf(day))).collect(Collectors.toList());
    }

    @Override
    protected List<BigDecimal> calc(List<RentAmount> rentAmounts) {
        return rentAmounts.stream().map(DayMeanAlloter::toAmount).flatMap(Collection::stream).collect(Collectors.toList());
    }
}
